<template>
  <div class="content">
    <div v-html="content"></div>
  </div>
</template>

<script>
  export default {
    name: "index",
    data(){
      return{
        content: ''
      }
    },
    onLoad(query){
      console.log(query)
      if (query.type == 'agreement'){
        this.getServiceAgreement();
      } else {
        this.getGroupRule();
      }
    },
    methods:{
      //获取拼团规则
      async getGroupRule(){
        const res = await this.$request.getData('/other/getGroupRule');
        if (res.data.level == 'success'){
          let str = res.data.data.content;
          str = str.replace(/<img[^>]*>/gi, function (match, capture) {
            return match.replace(/style\s*?=\s*?([‘"])[\s\S]*?\1/ig, '')
          });
          str = str.replace(/\<img/gi, '<img style="max-width:100%;height:auto" ');
          this.content = str;
        }
      },

      //获取服务协议
      async getServiceAgreement(){
        const res = await this.$request.getData('/other/getServiceAgreement');
        if (res.data.level == 'success'){
          let str = res.data.data.content;
          str = str.replace(/<img[^>]*>/gi, function (match, capture) {
            return match.replace(/style\s*?=\s*?([‘"])[\s\S]*?\1/ig, '')
          });
          str = str.replace(/\<img/gi, '<img style="max-width:100%;height:auto" ');
          this.content = str;
        }
      }
    }
  }
</script>

<style scoped lang="scss">
.content{
  padding: 30rpx;
}
</style>
